home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CD Exchange
/
CD Exchange - Volume 1.iso
/
utils
/
misc
/
machv
/
programmer.lha
/
docs
/
pgm.doc
< prev
Wrap
Text File
|
1993-09-20
|
3KB
|
89 lines
MachIV opens mach.library, reads in the configuration settings and fills
in mach.library variables. These may then be accessed and modified by
other programs. In particular, the macro list may be walked and macros may
be changed.
There are several library functions (detailed in mach.doc) for finding,
creating, and changing macros. There is also a function for putting up
a list of macro names, window and screen names, and configuration titles.
In the library base is a semaphore structure that should be 'Obtained'
before examining or modifying any macro. There are two example programs
in the autodoc file mach.doc, and the programs 'PrintMacros' and 'Vars'
also show how to access the library.
In brief, the library has the List struct ml_ConfigHead which is a list
of MachCfg structs, one for each configuration that the user may have.
In the MachCfg struct are the settings that the users has selected and
an array of 128 List structs each of which contains a list of macros. All
hotkeys for a specific keycode are contained in one list. The keycode of
the hotkey is used as the index into the array.
For example:
MachBase->ml_ConfigHead.lh_Head->mc_Hotkeys[0x45].lh_Head->mo_Macro
points to the first macro attached to the ESC key (0x45). This actually
would need extensive casting or assignments to variables:
mac = ((struct MacroObject*)(((struct MachCfg*)(MachBase->ml_ConfigHead.lh_Head))->mc_Hotkeys[0x45].lh_Head))->mo_Macro;
or
struct MachCfg *cfg;
struct MacroObject *mo;
cfg = (struct MachCfg *)MachBase->ml_ConfigHead.lh_Head;
mo = (struct MacroObject *)cfg->mc_Hotkeys[0x45].lh_Head;
mac = mo->mo_Macro;
Of course it is easier to use a library funtion like:
char string[] = "macro text";
UWORD key = 0x45;
UWORD qualifiers = IEQUALIFIER_CONTROL;
if (mo = NewMacroObject(cfg,string,key,qualifiers)) {
printf("%s\n",mo->mo_Macro );
}
Some events may be simply set in ml_GeneralEvent or ml_MouseEvent and then
signal MachV. The events for loading, saving, adding and deleting of
configurations and GE_DO_VAR must use PutMsg().
Signal like this:
MachBase->ml_GeneralEvent |= GE_BEEP;
Signal(MachBase->ml_MachV_Task.Task, MachBase->ml_MachV_Task.Sig);
Sending a message to MachV is done in a method similar to this:
void putmsg_machv(long ev)
{
struct MsgPort *rp;
rp = CreatePort(NULL,0L);
if (rp) {
machmsg.mm_Msg.mn_ReplyPort = rp;
machmsg.mm_Msg.mn_Node.ln_Name = "MACHV";
machmsg.mm_Command = MACHV_GENERAL_EVENT;
machmsg.mm_SubCommand = ev; /* may be GE_LOADCONFIG, GE_ADDCONFIG etc. */
PutMsg(MachBase->ml_MsgPort,(struct Message*)&machmsg); /* tell MachV */
WaitPort(rp); /* wait for reply */
GetMsg(rp); /* get reply */
DeletePort(rp);
}
}
The autodoc examples, PrintMacros.c and vars.c should give a sufficient
start for anyone wishing to write their own interface to MachIV. More
information will be made available in the future.